import pwm from '../dxmodules/dxPwm.js'
import * as os from "os"

// ID Info 4000 Buzzer/Light On
const PWM_BEEP_CHANNEL_DW200 = 4
const PWM_BEEP_PERIOD_NS_DW200 = 366166
// Duty cycle, where 50 can be considered as loudness/brightness.
const PWM_DUTY_DW200 = PWM_BEEP_PERIOD_NS_DW200 * 50 / 255

// Initialize PWM
let resp = pwm.request(PWM_BEEP_CHANNEL_DW200);

// Set PWM period
resp = pwm.setPeriodByChannel(PWM_BEEP_CHANNEL_DW200, PWM_BEEP_PERIOD_NS_DW200)

// Application Channel
resp = pwm.enable(PWM_BEEP_CHANNEL_DW200, true)

// PWM - Short beep/flash
pwm.setDutyByChannel(PWM_BEEP_CHANNEL_DW200, PWM_DUTY_DW200)

// Short beep/flicker 100ms
os.sleep(100)

// Turn off PWM, otherwise the buzzer/light will keep on.
pwm.setDutyByChannel(PWM_BEEP_CHANNEL_DW200, 0)


